﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProcessFile
{
   public class StkFile
   {
       public string _filePath;
       public string[] _lines;
       public StkFile(string filePath)
       {
           _filePath = filePath;
           _lines = Common.ReadFileText(filePath);
       }
    
       public int UnitLine
       {
           get
           {
            for (int i = 0; i <_lines.Length ; i++)
			{
			    if (_lines[i].Trim()=="um"||_lines[i].Trim()=="mil")
			    {
			        return i;
			    }
			    
			}
            return -1;
           }            
       }
       public int TopSolder
       {
           get { return 0; }
           
       }
       public int TopLayer
       {
           get
           {
               for (int i = 0; i < _lines.Length; i++)
               {
                   if (Common.CheckLayer(_lines[i]))
                   {
                       return i;
                   }
               }
               return -1;
           }

       }
       public int BottomLayer
       {
           get
           {
               for (int i = UnitLine; i >0; i--)
               {
                   if (Common.CheckLayer(_lines[i]))
                   {
                       return i;
                   }
               }
               return -1;
           }

       }
       public int ViaLineIndex
       {
           get
           {
               int unitIndex = UnitLine;
               for (int i = unitIndex+1; i < _lines.Length; i++)
               {
                   string[] item = _lines[i].Split(Common.SplipChar);
                   if (item[0].ToLower().Contains("via"))
                   {
                       return i;
                   }
               }
               return -1;
           }
       }
       public int BottomSolder
       {
           get
           {
               for (int i = UnitLine; i > 0; i--)
               {
                   if (Common.CheckIsDielectric(_lines[i]))
                   {
                       return i;
                   }
               }
               return -1;
           }

       }
    }
}
